package com.example.jdbc.extend;

import com.mysql.jdbc.JDBC4Connection;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.Properties;

/**
 * @program: sms
 * @description:
 * @author: zhanghz001
 * @create: 2020-11-09 15:04
 **/
public class MyConnection1 extends JDBC4Connection {

    private Connection con;
    private List<Connection> pool;

    public MyConnection1(String hostToConnectTo, int portToConnectTo,
                         Properties info, String databaseToConnectTo, String url
            , Connection con, List<Connection> list) throws SQLException {
        super(hostToConnectTo, portToConnectTo, info, databaseToConnectTo, url);
        this.con = con;
        this.pool = list;
    }

    //重写close方法
    @Override
    public void close() throws SQLException {
        pool.add(con);
    }
}
